package com.tiheima.service.impl;

import com.github.pagehelper.PageInfo;
import com.tiheima.mapper.LogMapper;
import com.tiheima.model.dos.LogListDO;
import com.tiheima.model.dto.LogPageQuery;
import com.tiheima.model.result.PageResult;
import com.tiheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {

    private final LogMapper logMapper;

    public LogServiceImpl(LogMapper logMapper) {
        this.logMapper = logMapper;
    }

    @Override
    public PageResult<LogListDO> page(LogPageQuery logPageQuery) {
        List<LogListDO> list = logMapper.page(logPageQuery);
        PageInfo<LogListDO> pageResult = new PageInfo<>(list);
        return PageResult.of(pageResult.getTotal(), pageResult.getList());
    }
}
